package com.yaorange.module.system.service.impl;

import com.yaorange.module.system.repository.SysRolePermissionRepository;
import com.yaorange.module.system.service.SysRolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 15332
 * @version 1.0
 * @date 2025/6/19 15:23
 * @description 角色权限关联业务层
 */
@Service
public class SysRolePermissionServiceImpl implements SysRolePermissionService {

  @Autowired
  private SysRolePermissionRepository repository;
  /**
   * 根据角色的ID删除对应的权限信息
   * @param id
   */
  @Override
  public void deleteByRoleId(Long id) {
    repository.deletePermByRoleId(id);

  }

  /**
   * 根据角色的ID获取到角色对应的权限id
   * @param id
   * @return
   */
  @Override
  public List<Long> selectPermById(Long id) {
    List<Long> ids = repository.selectPermById(id);
    return ids;
  }

  /**
   * 为用户指定权限
   * @param ids
   * @param id
   */
  @Override
  public void insertPermList(List<Long> ids, Long id) {
    if (ids!=null && ids.size()>0){
      repository.insert(ids,id);
    }
  }
}
